﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iOak.Domain.Campaigns;
using iOak.Data.Campaigns;
using iOak.Business.Resumes;

namespace iOak.Business.Campaigns
{
    public class CampaignService
    {

        private CampaignRepository _campaignRepository;
        public CampaignService()
        {
            _campaignRepository = new CampaignRepository("master");
        }

        public void Create(Campaign campaign)
        {
            _campaignRepository.Create(campaign);
        }

        public Campaign Retrieve(Guid campaignId)
        {
            return _campaignRepository.Retrieve(campaignId);
        }

        public void Update(Campaign campaign)
        {
            _campaignRepository.Update(campaign);
        }

        public void Delete(Guid campaignId)
        {
            _campaignRepository.Delete(campaignId);
        }

        public List<Campaign> LoadAll()
        {
            return _campaignRepository.LoadAll();
        }

        /// <summary>
        /// 检索申报信息
        /// </summary>
        /// <param name="subject">申报名称</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="status">状态</param>
        /// <returns>申报信息</returns>
        public List<Campaign> FindCampaigns(String subject, DateTime? startDate, DateTime? endDate, int? status)
        {
            return _campaignRepository.FindCampaigns(subject, startDate, endDate, status);
        }

        /// <summary>
        /// 获取没有生成Application的数据
        /// </summary>
        /// <returns>返回结果</returns>
        public List<Campaign> SearchByNotApplication()
        {
            return _campaignRepository.SearchByNotApplication();
        }

        /// <summary>
        /// 根据Application状态检索数据
        /// </summary>
        /// <param name="status">状态</param>
        /// <returns>返回结果</returns>
        public List<Campaign> GetListByApplicationStatus(Guid companyId, int status)
        {

            return _campaignRepository.GetListByApplicationStatus(companyId, status);
        }

        public List<Campaign> GetListCanBeUsedByCompany(Guid companyId, int? status = null)
        {
            return _campaignRepository.GetListCanBeUsedByCompany(companyId, status);
        }

        public List<Campaign> GetListCanSubmit(Guid companyId)
        {
            return _campaignRepository.GetListCanSubmit(companyId);
        }

        public List<Campaign> GetListRemindCompany(Guid companyId)
        {
            return _campaignRepository.GetListRemindCompany(companyId);
        }

        public List<Campaign> GetListByStatus()
        {
            return _campaignRepository.GetListByStatus();
        }

    }
}
